<template>
    <div>
        <el-form label-width="80px" label-position="left" >
            <el-form-item label="用户名" prop="username" >
                <el-input v-model="Form.username" placeholder="用户名/邮箱"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input type="password" v-model="Form.password" autocomplete="off" placeholder="密码"></el-input>
            </el-form-item>
             <el-form-item> 
                <el-button type="primary" @click="login">登录</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    data() {
        return {
            Form: {
                id:'',
                username: '',
                password: '',
            }
      };
    },
    methods: {
      login(){ 
          this.$axios.post("/findUsername2",{
              username:this.Form.username,
              password:this.Form.password,
          })
        .then((res)=>{
                
                if(res.data.code == 200){
                    console.log(res);
                    this.$router.push("/home");
                }
                else{
                    alert("密码或用户名错误")
                }
                return res})
        .catch((err)=>{return err});
      },
      login2(){
        this.$axios.post("/saveUser",{
                  username:this.Form.username,
                  password:this.Form.password
          })
            .then((res)=>{
                console.log(res);
                return res})
            .catch((err)=>{
                console.log(err);
            });
      },
      loginTest(){
          console.log("username:"+this.Form.username);
          console.log("password:"+this.Form.password);
      },
    }
  }

</script>

<style>
    
</style>